﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Syspetro.Core.GoogleAuth.Google1
{
    public class GoogleAuthenticatorProvider1 : IGoogleAuthenticatorProvider1
    {
        private readonly GoogleAuthOptions options;
        private readonly GoogleAuthenticator1 authenticator;

        public GoogleAuthenticatorProvider1()
        {
            options = new GoogleAuthOptions();
            InternalApp.Configuration.Bind("GoogleAuthOptions", options);
            authenticator = new GoogleAuthenticator1();
        }

        public bool Validate(string uid, string salt, string twofactor_code)
        {
            return authenticator.Validate(options.Alias, uid, salt, twofactor_code);
        }

        public GoogleAuthenticatorBinding1 Generate(string uid, string username)
        {
            return GoogleAuthenticator1.Generate(options.Issuer, options.Alias, uid, username);
        }
    }
}
